package com.j283_5.wisdom_park.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.j283_5.wisdom_park.vo.device_management.DeviceInformationVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.sql.Timestamp;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author laoda
 * @since 2022-04-28
 */
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class DeviceInformation implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 设备信息id
     */
    @TableId(value = "dinf_id", type = IdType.AUTO)
    private Integer dinfId;

    /**
     * 设备名称
     */
    private String ddetName;

    /**
     * 设备编号
     */
    private String ddetNumber;

    /**
     * 设备型号
     */
    private String ddetType;

    /**
     * 安装位置
     */
    private String dinfLocation;

    /**
     * 0:为运行状态正常，1：为异常
     */
    private Integer dinfState;

    /**
     * 运行时常
     */
    private Integer dinfRuntime;

    /**
     * 设备最近更新时间
     */
    private Timestamp dinfUpdate;

    /**
     * 设备类型名称
     */
    private String ddetStyle;
    public DeviceInformation(DeviceInformationVo deviceInformationVo){
        this.dinfId = deviceInformationVo.getDinfId();
        this.ddetName = deviceInformationVo.getDdetName();
        this.ddetNumber = deviceInformationVo.getDdetNumber();
        this.ddetType = deviceInformationVo.getDdetType();
        this.dinfLocation = deviceInformationVo.getDinfLocation();
        if (deviceInformationVo.getDinfState() != null) {
            setDinfState(deviceInformationVo.getDinfState());
        }
        this.dinfRuntime = deviceInformationVo.getDinfRuntime();
        this.dinfUpdate = deviceInformationVo.getDinfUpdate();
        this.ddetStyle = deviceInformationVo.getDdetStyle();
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Integer getDinfId() {
        return dinfId;
    }

    public void setDinfId(Integer dinfId) {
        this.dinfId = dinfId;
    }

    public String getDdetName() {
        return ddetName;
    }

    public void setDdetName(String ddetName) {
        this.ddetName = ddetName;
    }

    public String getDdetNumber() {
        return ddetNumber;
    }

    public void setDdetNumber(String ddetNumber) {
        this.ddetNumber = ddetNumber;
    }

    public String getDdetType() {
        return ddetType;
    }

    public void setDdetType(String ddetType) {
        this.ddetType = ddetType;
    }

    public String getDinfLocation() {
        return dinfLocation;
    }

    public void setDinfLocation(String dinfLocation) {
        this.dinfLocation = dinfLocation;
    }

    public Integer getDinfState() {
        return dinfState;
    }

    public void setDinfState(Integer dinfState) {
        this.dinfState = dinfState;
    }

    public Integer getDinfRuntime() {
        return dinfRuntime;
    }

    public void setDinfRuntime(Integer dinfRuntime) {
        this.dinfRuntime = dinfRuntime;
    }

    public Timestamp getDinfUpdate() {
        return dinfUpdate;
    }

    public void setDinfUpdate(Timestamp dinfUpdate) {
        this.dinfUpdate = dinfUpdate;
    }

    public String getDdetStyle() {
        return ddetStyle;
    }

    public void setDdetStyle(String ddetStyle) {
        this.ddetStyle = ddetStyle;
    }



    public void setDinfState(String dinfState){
        switch (dinfState){
            case "正常":
                this.dinfState = 0;
                return;
            case "禁用":
                this.dinfState = 1;
                return;
            case "异常":
                this.dinfState = 2;
                return;
        }
    }
}
